<!DOCTYPE html>
<title>Test that setting src to an invalid url triggers load(), which sets networkState to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loading events and end up with networkState >= NETWORK_LOADING.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");
    video.onloadstart = t.step_func(function() {});
    video.onloadedmetadata = t.step_func(function() {});
    video.onloadeddata = t.step_func(function() {});
    video.oncanplay = t.step_func(function() {});
    video.onplay = t.unreached_func();
    video.onplaying = t.unreached_func();

    video.onerror = t.step_func(function() {
        assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
        // now set a valid url
        video.src = "content/test.ogv";
    });

    video.oncanplaythrough = t.step_func_done(function () {
        assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWORK_IDLE);
    });

    // first set the src to a bogus url, it should attempt a load
    assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY);
    video.src = "bogus/movie.mpg";
});
</script>